import Vue from 'vue';
import './plugins/axios';
import App from './App.vue';
import store from './store';
import router from './router';
import vuetify from './plugins/vuetify';
import VueEditor from 'vue-md-editor';
import api from './api/api.js';
// 配置cookie
import cookie from 'vue-cookie';
import VCharts from 'v-charts'

Vue.use(VCharts)

Vue.prototype.$cookie = cookie;  //配置时候prototype.$这里的名字自己定义不是固定是cookie
Vue.config.productionTip = false;
Vue.prototype.$api = api;
router.beforeEach((to, from, next) =>{
  if (to.meta.title) {
    document.title = to.meta.title;
  }
  const type = to.meta.type;
  // 判断该路由是否需要登录权限
  if (type === 'Login') {
    if (window.localStorage.getItem('loginstatus')) {
      next()
    } else {
      next('/Login')
    }
  } else {
    next()  // 确保一定要有next()被调用
  }
});

new Vue({
  store,
  router,
  vuetify,
  VueEditor,
  render: h => h(App)
}).$mount('#app')
